package com.hongye.house.service.impl;

import com.hongye.common.entity.AgentUserEntity;
import com.hongye.house.entity.HongyeBannerEntity;
import com.hongye.house.entity.NewsHomeEntity;
import com.hongye.house.entity.PropertiesSaleHomeEntity;
import com.hongye.house.fegin.ProprietaryFeign;
import com.hongye.house.service.HongyeBannerService;
import com.hongye.house.service.NewsHomeService;
import com.hongye.house.service.PropertiesSaleHomeService;
import com.hongye.house.vo.ClientListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.Query;

import com.hongye.house.dao.ClientHomeDao;
import com.hongye.house.entity.ClientHomeEntity;
import com.hongye.house.service.ClientHomeService;


@Service("clientHomeService")
public class ClientHomeServiceImpl extends ServiceImpl<ClientHomeDao, ClientHomeEntity> implements ClientHomeService {

    //轮播图表
    @Autowired
    HongyeBannerService hongyeBannerService;

    //功能列表
    @Autowired
    ClientHomeService clientHomeService;

    //咨询列表
    @Autowired
    NewsHomeService newsHomeService;

    //楼盘列表
    @Autowired
    PropertiesSaleHomeService propertiesSaleHomeService;

    //经纪人调用
    @Autowired
    ProprietaryFeign proprietaryFeign;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ClientHomeEntity> page = this.page(
                new Query<ClientHomeEntity>().getPage(params),
                new QueryWrapper<ClientHomeEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public ClientListVo clientList() {
        ClientListVo clientListVo = new ClientListVo();
        List<HongyeBannerEntity> banners = hongyeBannerService.list();
        //功能列表
        List<ClientHomeEntity> clientHome = clientHomeService.list();
        //热门咨询列表
        List<NewsHomeEntity> news=newsHomeService.hotlist();
        //热门楼盘列表
        List<PropertiesSaleHomeEntity> saleHomeEntities=propertiesSaleHomeService.hotSaleHome();
        //热门经济人
        List<AgentUserEntity> agents=proprietaryFeign.hotagent();
        clientListVo.setAgentUsers(agents);
        clientListVo.setBanner(banners);
        clientListVo.setClienthome(clientHome);
        clientListVo.setNews(news);
        clientListVo.setSaleHome(saleHomeEntities);
        return clientListVo;
    }

}